package com.why.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.why.entity.Courseselection;
import com.why.service.CourseselectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (Courseselection)表控制层
 *
 * @author makejava
 * @since 2023-05-23 15:28:15
 */
@RestController
@RequestMapping("/courseselection")
public class CourseselectionController {
    /**
     * 服务对象
     */
    @Autowired
    private CourseselectionService courseselectionService;

    @PostMapping("/save")
    public String save(@RequestBody Courseselection courseselection) {
        if (courseselection.getStudentid() == null || courseselection.getXueshengxingming() == null) {
            return "no";
        } else {
            courseselectionService.save(courseselection);
            return "success";
        }
    }

    @DeleteMapping("/delete/{id}")
    public String delete(@PathVariable("id") Long id) {
        LambdaQueryWrapper<Courseselection> queryWrapper = new LambdaQueryWrapper<Courseselection>();
        queryWrapper.eq(Courseselection::getId, id);
        Courseselection one = courseselectionService.getOne(queryWrapper);
        if (one != null) {
            courseselectionService.removeById(id);
            return "success";
        } else {
            return "no";
        }
    }


}

